package com.foton.mybatis.factory;

import com.foton.mybatis.configration.Configration;

import java.io.InputStream;

/**
 * @Author RenPu
 * @Date 2023/3/29 15:49
 * @Version 1.0
 * @Description: 解析构建xml内的k-v值
 **/
public class SqlSessionFactoryBuilder {


    public static SqlSessionFactory builder(String filePath) {
        InputStream resourceAsStream = SqlSessionFactoryBuilder.class.getClassLoader().getResourceAsStream(filePath);
        return builder(resourceAsStream);
    }

    /**
     * 构建DefauletSqlSessionFactory，同时设置Configration对象
     * @param resourceAsStream
     * @return
     */
    private static SqlSessionFactory builder(InputStream resourceAsStream){
        Configration.propertise.load(resourceAsStream);
        return new DefauletSqlSessionFactory(new Configration());

    }

}
